<% if has_transition?(@assembly.ciId) %>
  <% action_name = action.downcase %>
  <% case action_name %>
  <% when 'deploy' %>
    <%= form_for @deployment,
                 :url  => assembly_transition_environment_deployments_path(@assembly, @environment),
                 :html => {:method => :post, :remote => true, :class => 'deploy-action'} do |f| %>
      <%= error_messages_for(@deployment) %>
      <%= hidden_field_tag :exclude_platforms, params[:exclude_platforms] %>
      <%= f.hidden_field :releaseId %>
      <%= f.hidden_field :nsPath %>
      <%= f.hidden_field :continueOnFailure %>
      <% ops = defined?(warning) && warning ? warning : ''
         if @override.present?
           ops += ";\n" if ops.present?
           ops += override_desc
         end %>
      <%= f.hidden_field :ops, :value => ops %>
      <%= f.hidden_field :override_password, :value => '' if @override %>
      <% override_desc = @override && @override.keys.join(' ')
         comments = @manifest.description
         if @override.present?
           comments += ";\n" if comments.present?
           comments += override_desc
         end %>
      <%= f.text_area :comments, :value => comments, :placeholder => 'comments', :class => 'input-xxlarge' %>
      <br>
      <%= f.button((icon('check', 'Deploy')), :data => {:disable_with => 'Deploying...'}, :class => 'btn btn-success', :name => 'deploy', :disabled => @override) %>
    <% end %>
  <% else %>
    <%= form_for @deployment,
                 :url  => assembly_transition_environment_deployment_path(@assembly, @environment, @deployment),
                 :html => {:method => :put, :remote => true} do |f| %>
      <%= error_messages_for(@deployment) %>
      <% case action_name %>
      <% when 'cancel' %>
        <%= f.hidden_field :deploymentState, :value => 'canceled' %>
        <%= f.button(icon('ban', 'Cancel'), :data => {:disable_with => 'Canceling...'}, :class => 'btn btn-danger') %>
      <% when 'retry' %>
        <%= f.hidden_field :deploymentState, :value => 'active' %>
        <%= f.hidden_field :continueOnFailure %>
        <%= f.button(icon('repeat', 'Retry'), :data => {:disable_with => 'Retrying...'}, :class => 'btn btn-success') %>
      <% when 'pause' %>
        <%= f.hidden_field :deploymentState, :value => 'paused' %>
        <%= f.button(icon('pause', 'Pause'), :data => {:disable_with => 'Pausing...'}, :class => 'btn btn-warning') %>
      <% when 'resume' %>
        <%= f.hidden_field :deploymentState, :value => 'active' %>
        <%= f.button(icon('play', 'Resume'), :data => {:disable_with => 'Resuming...'}, :class => 'btn btn-success') %>
      <% end %>
    <% end %>
  <% end %>
<% end %>
